#!/usr/bin/env/python
# -*- coding: utf-8 -*- 

# @File : Smtp.py 
# @Author : t_fengyun
# @Time : 2019/9/10 15:10 
# @desc : there is description 

import smtplib
from email.mime.text import MIMEText
from  email.header import Header

'''发送的邮箱和密码'''
sender = '17666***@163.com'
password = 'moer15211***'

'''接收者的邮箱'''
mailto_list  = ['129961***@qq.com','3155***@qq.com']
'''服务器地址(登录你的服务器邮箱,找到服务器地址。我用的163邮箱)'''
smtp_server  = 'smtp.163.com'

msg = MIMEText('python send email test','plain','utf-8')

msg['From'] = sender
msg['To'] = ';'.join(mailto_list)

'''主题'''
subject = 'python smtp test'
msg['Subject'] = Header(subject,'utf-8')

try:
    smtpObj = smtplib.SMTP(smtp_server,25)
    smtpObj.login(sender,password)
    smtpObj.set_debuglevel(1)
    smtpObj.sendmail(sender,mailto_list,msg.as_string())
    smtpObj.quit()
    print('send email success')
except smtplib.SMTPException:
    print('Error:email fail')

